// index.js
// 获取应用实例
const app = getApp()

Page({
  data: {
  },
  onLoad() {
    var that=this
    const username = wx.getStorageSync('username');
    if(username!=''){
      app.comrequest('https://ipass.cc/sqacticity/acapi/outputphp.php',{num:2,username:username}).then(res=>{
        that.setData({
          userid:res[0].id
        })
        var userstate2=res[0].state2
        if(userstate2==null){
          that.setData({
            state:false
          })
        }else{
          that.setData({
            state:true
          })
        }
      })
    }else{
      that.setData({
        state:true
      })
    }

  },
  state1click(){
    var that=this
    wx.getUserProfile({
      desc: '展示用户信息', // 声明获取用户个人信息后的用途，后续会展示在弹窗中，请谨慎填写
      success: (res) => {
        var username=res.userInfo.nickName
        wx.setStorageSync('username', username)
        app.comrequest('https://ipass.cc/sqacticity/acapi/outputphp.php',{num:1,username:username}).then(res=>{
          wx.showToast({
            title: res,
          })
        })
      }
    })
    that.onLoad()
  },
  state1click2(){
    var that=this
    app.comrequest('https://ipass.cc/sqacticity/acapi/outputphp.php',{num:3,userid:that.data.userid}).then(res=>{
      wx.showToast({
        title: res,
      })
    })
  }
})
